package com.hyts.infodb.zuul.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.zuul.RoutesRefreshedEvent;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * project-name:infodb
 * package-name:com.hyts.infodb.zuul.service
 * author:Libo/Alex
 * create-date:2019-05-22 22:04
 * copyright:libo-hyts-github
 * email:libo2dev@aliyun.com
 * description:此类主要用于: 路由刷新服务
 */
@Service
public class RefreshRouteService {


    @Autowired
    ApplicationEventPublisher publisher;

    @Resource(name="customRouteLocator")
    RouteLocator routeLocator;


    public void refreshRoute(){
        RoutesRefreshedEvent routesRefreshedEvent = new RoutesRefreshedEvent(routeLocator);
        publisher.publishEvent(routesRefreshedEvent);
    }


}
